#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include<QMessageBox>
#include<QDebug>
#include<QPen>
#include<QRadialGradient>
#include<QBrush>
#include<QGraphicsEllipseItem>
#include<QGraphicsItem>
#include<QGraphicsView>
#include<QMouseEvent>
#include<QColorDialog>
#include<QVBoxLayout>
#include<QLabel>
#include<QPalette>
#include<QWidget>

QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();


signals:
    void signalShowAdjust();
    void signalCloseFormMain();

private:
    Ui::MainWindow *ui;
    QGraphicsScene * scene;
    QGraphicsView * view;
    int currentPlayer = 1;
    int totalPlayer = 2;
    int*** board;
    int ** Qi;
    void drawPiece(int x , int y , int currentPlayer);
    void countQi(int x , int y , int currentPlayer , int towards);
    bool checkWin(int x,int y);
    void initBoard();
    int boardWidthSize = 25;
    int boardHeightSize = 25;
    const int CELL_SIZE = 40;
    int down = 0;
    int up = 0;
    int left = 0;
    int right = 0;
    bool ifConfirm = false;
    bool ifSelect = false;
    bool retHorizontal = false;
    bool retVertical = false;
    bool retSlantLeft = false;
    bool retSlantRight = false;
    void remove(int k, int CurrentPlayer);
    QRadialGradient * gradient;
    QGraphicsEllipseItem *** piece;
    int condition = 5;
    QColor * color;
    QLabel * winner;
    QLabel * winWay;
    QVBoxLayout * winLayout;
    QWidget * winWidget;
private slots:
    void mousePressEvent(QMouseEvent * event)override;
    void changeBoardWidthSizeValue(int BoardWidthSize);
    void changeBoardHeightSizeValue(int BoardHeightSize);
    void changeTotalPlayerValue(int TotalPlayer);
    void ifConfirmAct(bool ret);
    void receivedColor(QColor * color);
    void recieveWinCondition(int Condition);
};
#endif // MAINWINDOW_H
